/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.stat;

import android.text.TextUtils;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.json.JSONObject;

public class i {
    private static String h = "EventBean";
    public String a = "";
    public long b = 0L;
    public String c = "";
    public long d = 0L;
    public long e = 0L;
    public long f = -1L;
    public Map g = null;

    public i() {}

    public i(String paramString, Map paramMap) {
        this.a = paramString;
        this.b = ai.o();
        this.g = paramMap;
    }

    public JSONObject a() {
        JSONObject localJSONObject = null;
        try {
            if (!(TextUtils.isEmpty(this.a))) {
                Map.Entry localEntry;
                String str1;
                String str2;
                Iterator localIterator;
                if (TextUtils.isEmpty(this.c)) {
                    localJSONObject = new JSONObject();
                    localJSONObject.put("qhId", this.a);
                    if (this.e > 0L) {
                        localJSONObject.put("qhBegin", this.d);
                        localJSONObject.put("qhEnd", this.e);
                        localJSONObject.put("qhDuration", this.f);
                    }
                    else if (this.d > 0L) {
                        localJSONObject.put("qhBegin", this.d);
                    }
                    else {
                        localJSONObject.put("qhTs", this.b);
                    }
                    if (this.g != null) {
                        localEntry = null;
                        str1 = null;
                        str2 = null;
                        localIterator = this.g.entrySet().iterator();
                        while (localIterator.hasNext()) {
                            localEntry = (Map.Entry) localIterator.next();
                            str1 = (String) localEntry.getKey();
                            str2 = (String) localEntry.getValue();
                            if (("qhId".equals(str1)) || ("qhTs".equals(str1)))
                                continue;
                            localJSONObject.put(str1, str2);
                        }
                    }
                }
                else if (("end".equals(this.c)) || ("begin".equals(this.c))) {
                    localJSONObject = new JSONObject();
                    localJSONObject.put("qhId", this.a);
                    localJSONObject.put("qhBegin", this.d);
                    if ("end".equals(this.c)) {
                        localJSONObject.put("qhEnd", this.e);
                        localJSONObject.put("qhDuration", this.f);
                    }
                    if (this.g != null) {
                        localEntry = null;
                        str1 = null;
                        str2 = null;
                        localIterator = this.g.entrySet().iterator();
                        while (localIterator.hasNext()) {
                            localEntry = (Map.Entry) localIterator.next();
                            str1 = (String) localEntry.getKey();
                            str2 = (String) localEntry.getValue();
                            if (("qhId".equals(str1)) || ("qhBegin".equals(str1)) || ("qhEnd".equals(str1))
                                    || ("qhDuration".equals(str1)))
                                continue;
                            localJSONObject.put(str1, str2);
                        }
                    }
                }
            }
        } catch (Exception localException) {
            x.a(h, localException);
        } catch (Error localError) {
            x.a(h, localError);
        }
        return localJSONObject;
    }
}